﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyStep.Attributes;
using EasyStep.Business.Interfaces;
using EasyStep.Business;
using EasyStep.Business.Constants;

using EasyStep.Business.Interfaces.Managers;
using System.IO;
using log4net;
using log4net.Config;
using EasyStep.TestExecution.Interfaces;


namespace EasyStep.WinForms
{
    public class TestDataContext : ITestDataContext
    {
        private ITestActionManager _ActionManager;
        public ITestActionManager ActionManager
        {
            get 
            {
                if (_ActionManager == null)
                    _ActionManager = ObjectManager.GetInstance<ITestActionManager>();
                return _ActionManager;
            }
            set
            {
                _ActionManager = value;
            }
        }

        private ITestConstantManager _ConstantsManager;
        public ITestConstantManager ConstantsManager
        {
            get
            {
                if (_ConstantsManager == null)
                    _ConstantsManager = ObjectManager.GetInstance<ITestConstantManager>();
                return _ConstantsManager;
            }
            set
            {
                _ConstantsManager = value;
            }
        }
        private ITestStepManager _TestStepManager;
        public ITestStepManager TestStepManager
        {
            get
            {
                if (_TestStepManager == null)
                    _TestStepManager = ObjectManager.GetInstance<ITestStepManager>();
                return _TestStepManager;
            }
            set
            {
                _TestStepManager = value;
            }
        }

        private ITestInfoManager _TestInfoManager;
        public ITestInfoManager TestInfoManager
        {
            get
            {
                if (_TestInfoManager == null)
                    _TestInfoManager = ObjectManager.GetInstance<ITestInfoManager>();
                return _TestInfoManager;
            }
            set
            {
                _TestInfoManager = value;
            }
        }

        public ITestHistoryManager _TestHistoryManager;
        public ITestHistoryManager TestHistoryManager
        {
            get
            {
                if (_TestHistoryManager == null) _TestHistoryManager = ObjectManager.GetInstance<ITestHistoryManager>();
                return _TestHistoryManager;
            }
            set { _TestHistoryManager = value; }
        }
        public IWebBrowserProxy[] RegisteredBrowsers { get; set; }
        public ILog Log { get; set; }
        private String _CurrentTest;
        public String CurrentTest
        {
            get
            {
                return _CurrentTest;
            }
            set { _CurrentTest = value; }
        }
        public String _CurrentProject;
        public String CurrentProject
        {
            get
            {
                return string.IsNullOrEmpty(_CurrentProject)
                    ? "%root%".TransformReplacements(PathReplacements)
                    : _CurrentProject;
            }
            set
            {
                _CurrentProject = value;
            }
        }

        public string Environment { get; set; }
        public Dictionary<string, string> PathReplacements { get; set; }
        public TestDataContext(string logRoot)
        {
            log4net.GlobalContext.Properties["LogRoot"] = logRoot;
            log4net.Config.XmlConfigurator.Configure();
            Log = LogManager.GetLogger("test_editor");
        }










        
    }
}
